package com.zuo.mall.controller;

import com.zuo.mall.common.api.CommonResult;
import com.zuo.mall.entity.OmsOrder;
import com.zuo.mall.entity.OmsOrderSetting;
import com.zuo.mall.mapper.OmsOrderMapper;
import com.zuo.mall.mapper.OmsOrderSettingMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api("订单设置")
@RequestMapping("orderSetting")
@RestController
public class OmsOrderSettingController {
    @Autowired
    private OmsOrderSettingMapper orderSettingMapper;
    @ApiOperation("获取指定的订单设置")
    @GetMapping("{id}")
    public CommonResult<OmsOrderSetting> getItem(@PathVariable Long id) {
        OmsOrderSetting omsOrderSetting = orderSettingMapper.selectById(id);
        return CommonResult.success(omsOrderSetting);
    }

    @ApiOperation("修改指定订单")
    @PostMapping("update/{id}")
    public CommonResult updateOrderSetting(@PathVariable Long id, @RequestBody OmsOrderSetting orderSetting) {
        OmsOrderSetting omsOrderSetting = orderSetting.setId(id);
        int count = orderSettingMapper.updateById(omsOrderSetting);
        if (count > 0) {
            return CommonResult.success(count);
        }
        return CommonResult.failed();
    }
}
